<?php get_instance()->view('common/header');?>
<style>
    .content-btn-box,.content-box{margin-top:10px;}
    .container {
        width: 100%;
    }
    .add-tag-btn{line-height: 40px;}
    .option-item {
        margin-bottom: 5px;
        position: relative;
    }
    .del-tag-btn{font-size: 14px;line-height: 36px;display: block;margin-bottom: 4px;}
    .del-tag-btn a{color: red;}
    .add-img{margin-top: 9px;float: left;left: 0;}
    .radio-list{float: left;}
    .delete-btn{position: absolute;top: 0;width: 200px;}
    .img-box .img{width: 150px;height: 150px}
    .img-box .img1{width: 268px;height: 202px} /*单图高宽*/
    .img-box .img2{width: 216px;height: 216px} /*多图高宽*/
    .webuploader-container > div:nth-child(2){width: 78px !important;height: 34px !important;}
    #uploader-demo .uploader-list img{width: 120px;height: 100px}
    #uploader-demo .thumbnail {width: 120px;height: 100px}
    #filePicker .webuploader-pick img{width: 110px;height: 90px}
</style>
<div class="page-container home">
    <?php get_instance()->view('common/sidebar');?>
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                    <h3 class="page-title"> <?php echo $title;?></h3>
                    <ul class="page-breadcrumb breadcrumb">
                        <li class="btn-group"> <a class="btn default ml_5 return" href="<?php echo getUrl('dailyMenus');?>"><i class="fa fa-chevron-left"></i> 返回</a> </li>
                        <li><i class="fa fa-home"></i><a href="<?php echo getUrl('dailyMenus');?>">每日菜单 </a><i class="fa fa-angle-right"></i></li>
                        <li><a href="javascript:void(0);"><?php echo $add ? '添加' : '编辑';?></a></li>
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN VALIDATION STATES-->
                    <div class="portlet box">
                        <div class="portlet-body form">
                            <!-- BEGIN FORM-->
                            <form action="<?php echo getUrl('dailyMenus/save')?>" class="form-horizontal" method="post" id="main-form" novalidate="novalidate">
                                <div class="form-body">
                                    <div class="form-group">
                                        <label class="control-label col-md-2">图片<span class="required">*</span></label>
                                        <div class="col-md-6">
                                            <div class="cropitMaster-box" style="width:124px;height:124px;&quot;">
                                                <img style="width:100%;height:100%;" id="icn-img" alt="" src="<?php echo ! $add ? $info['pic'] : getDefaultImg();?>">
                                            </div>
                                            <a class="upload-btn" href="javascript:void(0);">选择上传图片（750*500）</a>
                                            <input type="hidden" name="icon" id="pic" >
                                        </div>
                                        <script type="text/javascript">
                                            $(function () {
                                                cropitMaster({
                                                    uploadBtn:$('.upload-btn'),
                                                    height:'500px',
                                                    width:'750px',
                                                    complete:function(btn,data){
                                                        $('#icn-img').attr('src', data);
                                                        $('#pic').val(data).change();
                                                    }
                                                });
                                            })
                                        </script>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-2">标题<span class="required">*</span></label>
                                        <div class="col-md-9">
                                            <input class="form-control required" name="title" type="text" value="<?php echo ! $add ? $info['title'] : '';?>">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-2">制作时间<span class="required">*</span></label>
                                        <div class="col-md-9">
                                            <input class="form-control required" name="production_time" type="text" value="<?php echo ! $add ? $info['production_time'] : '';?>">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-2">简介<span class="required">*</span></label>
                                        <div class="col-md-9">
                                            <textarea class="form-control required" rows="3" name="desc"><?php echo ! $add ? $info['desc'] : '';?></textarea>

                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-2">内容<span class="required">*</span></label>
                                        <div class="col-md-9" >
                                            <script id="content" name="content" type="text/plain" ><?php echo !$add ? $info['content'] : ''?></script>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-2">是否推荐<span class="required"></span></label>
                                        <div class="col-md-9" style="margin-left: 18px;">
                                            <div class="radio-list">
                                                <label class="radio-inline"><input name="is_recommend" <?php if((! $add && $info['is_recommend'] == 1 ) || $add):?> checked<?php endif;?> value="1" type="radio"> 普通 </label>
                                                <label class="radio-inline"><input name="is_recommend" <?php if(! $add && $info['is_recommend'] == 2):?> checked<?php endif;?> value="2" type="radio"> 置顶 </label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-actionsc fluid">
                                        <div class="col-md-offset-2 col-md-9" style="padding-left: 0;">
                                            <input name="id" value="<?php echo ! $add ? $info['id'] : '';?>" type="hidden">
                                            <button class="btn green"><i class="fa fa-save"></i> 保存</button>
                                            <a class="btn default seach-btn" href="<?php echo getUrl('dailyMenus');?>"><i class="fa fa-chevron-left"></i> 返回</a>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <!-- END VALIDATION STATES-->
                </div>
                <!-- END PAGE CONTENT-->
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $.e_validate.init('#main-form', {});

        UE.getEditor('content',{initialFrameWidth:'100%',initialFrameHeight:'500',autoHeightEnabled:false,serverUrl:'<?php echo getUrl('dailyMenus/editor');?>'});
    });

    $(function(){
        setTimeout("$('.form-actions').width($('.form-body').innerWidth()).removeClass('hide');", '500');
        window.onresize = function(){
            $('.form-actions').width($('.form-body').innerWidth());
        }
    });
</script>
</body>
</html>